<?xml version="1.0" encoding="UTF-8" standalone="no"?><HBRRepo><variables/><rulesets/><rules><rule id="1" name="OFS_Rolling Trend Based Calc" product="Planning"><property name="application">HP4</property><property name="plantype">OEP_FS</property><property name="display_label">OFS_Rolling Trend Based Calc</property><property name="enableNotifications">false</property><property name="enablePostProcessing">false</property><property name="enablePreProcessing">false</property><property name="seeded">true</property><script type="groovy"><![CDATA[        DataGrid grid = null;
		def weeklyCondition
		boolean is13PeriodApp = TemporaryInternalMethods.is13PeriodApp()
		weeklyCondition = is13PeriodApp ? '(@ismbr(@remove(@relative("OEP_Weekly Plan", 0),"OEP_W53"))) or ("TP-Weeks" == 53 and @ismbr(@relative("OEP_Weekly Plan", 0)))' : '@ismbr(@relative("OEP_Weekly Plan", 0))'
		try {
        	grid = operation.grid;
        } catch(BindingsMissingException) {
        	throw new HspRuntimeException("ID_Err_FINANCIALS_TREND_BASED_TO_BE_RUN_FROM_FORM");
        }
        boolean processAccount = false;
        StringBuilder cscript = new StringBuilder(); // The variable that contains the actual script that will be returned at the end.
        List<DataGrid.HeaderCell> povs = grid.getPov();
        List<String> fixMembers = new ArrayList<String>();
        List<String> accts = new ArrayList<String>();
        for (DataGrid.HeaderCell cell : povs) {
            if (cell.isCalcableForPOV()) {
                if ((!(cell.isZoomable())) && !cell.getDimName().equals("Plan Element") && !cell.getDimName().equals("Scenario") ) {
                    fixMembers.add(cell.getEssbaseMbrName());
                } else if (cell.getDimName().equalsIgnoreCase("Account")) {
                     String memName = cell.getEssbaseMbrName();
                     if(memName == null)
                          memName = cell.getMbrName();
                     accts.add(memName);
                    processAccount = true;
                }
            }
        }

        List<DataGrid.Row> rows = grid.getRows();

        if (!processAccount) {
            for (DataGrid.Row row : rows) {
                List<DataGrid.HeaderCell> subRows = row.getHeaders();
                for (DataGrid.HeaderCell cell : subRows) {
                    if (cell.getDimName().equalsIgnoreCase("Account")) {
                      String memName = cell.getEssbaseMbrName();
                      if(memName == null)
                          memName = cell.getMbrName();
                       accts.add(memName);
                        processAccount = true;
                    } else {
                        break;
                    }
                }
            }
        }

        if (!processAccount) {
            List<List<DataGrid.HeaderCell>> cols = grid.getColumns();
            for (List<DataGrid.HeaderCell> cells : cols) {
                for (DataGrid.HeaderCell cell : cells) {
                    if (cell.getDimName().equalsIgnoreCase("Account")) {
                      String memName = cell.getEssbaseMbrName();
                      if(memName == null)
                          memName = cell.getMbrName();
                       accts.add(memName);
                        processAccount = true;
                    } else {
                        break;
                    }
                }
            }
        }

        int indx = 0;
		cscript.append('''FIX( "OEP_Rolling Forecast" ''');
        for (String fixMbr : fixMembers) {
            cscript.append(",\"" + fixMbr + "\"");
        }

        if (fixMembers.size() > 0)
             cscript.append(")\n");
	
        if (accts.size() > 0)
            processAccount = true;
        indx = 0;

        for (String acct : accts) {
            if (indx == 0) {
                String msg = "";
                cscript.append('''FIX(''');
            }

            cscript.append("\"" + acct + "\"");
            if (indx < (accts.size() - 1))
                cscript.append(",");
            indx++;
        }

      if (processAccount) {
             cscript.append(") \n");
			 
             	def weeklyCopyScript = '''Fix(BegBalance)																
                                            OFS_Trend(															
                                            IF(@ismbr(@remove(@list(&OEP_WeeklyRFRange,&OEP_RollingFCST,&OEP_QrtlyFCSTRF),&OEP_CurYr)))															
                                                IF(NOT(@ismbr("No Year")))														
                                                OFS_Trend=OFS_Trend->&OEP_CurYr;														
                                                "OFS_% Increase/(Decrease)"="OFS_% Increase/(Decrease)"->&OEP_CurYr;														
                                                endif														
                                            endif															
                                            )															
                                            ;															
                                        Endfix '''
                                        
			 	def nonWeeklycopyScript = '''Fix(BegBalance)
							OFS_Trend(
							IF(@ismbr(@remove(@list(&OEP_RollingFCST,&OEP_QrtlyFCSTRF),&OEP_CurYr)))
								IF(NOT(@ismbr("No Year")))
									OFS_Trend=OFS_Trend->&OEP_CurYr;
									"OFS_% Increase/(Decrease)"="OFS_% Increase/(Decrease)"->&OEP_CurYr;
								endif
							endif
							)
							;
							endfix '''
			boolean weeklyPlanExists = operation.application.getDimension(DimensionType.PERIOD, operation.cube).hasMember("OEP_Weekly Plan", operation.cube);
			
            if(weeklyPlanExists){
             	cscript.append(weeklyCopyScript);
            }else{
            	cscript.append(nonWeeklycopyScript);
            }
			
			cscript.append("\n \"OFS_Calculated\" ( \n");
            if(operation.application.currencyMode == CurrencyMode.SIMPLIFIED_MULTI_CURRENCY) {
            	 cscript.append("if(@ismbr(@relative(\"Input Currencies\",0))) \n ")
            }

			 def weeklyTrendLogic = """
             	If ("OFS_Trend"->BegBalance <> #Missing)															
                  if((@ismbr(@memberat(&OEP_RollingFCST,1)) and @ismbr(&OEP_FcstMnth:&OEP_EndMnth)) or (@ismbr(@remove(&OEP_RollingFCST, @list(&OEP_CurYr, @MEMBERAT(&OEP_RollingFCST, -1)))) and @ismbr(@relative("YearTotal",0))) or (@ismbr(@MEMBERAT(&OEP_RollingFCST, -1)) and @ismbr(&OEP_StartMnth:&OEP_RollingFCSTEnd)))																				
                        if(not(@ismbr("No Year"))) 
                          %Script(name:="Monthly_Trends") 													
                          %Script(name:="Forecast_Only_Trends")													
                          endif	        			
						endif
                  elseif(@ismbr(&OEP_WeeklyRFRange))    	
                      	if($weeklyCondition)
                          if((@ismbr(&OEP_CurYR) and Not(@ismbr(Week1:&OEP_CurWeek))) or (@ismbr(@remove(&OEP_WeeklyRFRange, @list(&OEP_CurYr, @MEMBERAT(&OEP_WeeklyRFRange, -1)))) and @ismbr(@relative("OEP_Weekly Plan",0))) or (@ismbr(@MEMBERAT(&OEP_WeeklyRFRange, -1)) and @ismbr(&OEP_WeeklyYr2Range)))							
                          if(not(@ismbr("No Year")))														
                              %Script(name:="Weekly_Trends")													
                              %Script(name:="Weekly_ForecastOnly")													
                          endif /*for endif on trend*/													
                          endif														
                      endif 
                      endif

                  elseif (@ismbr(&OEP_QrtlyFCSTRF))
                      if(@ismbr(@relative("OEP_Qrtly Plan", 0)))															
                          if(not(@ismbr("No Year")))														
                              %Script(name:="Qrtly_Trends")																									
                          endif		
                      endif
                  endif
              endif
            """
             
             def nonWeeklyTrendLogic = '''If ("OFS_Trend"->BegBalance <> #Missing)															
                            if((@ismbr(@memberat(&OEP_RollingFCST,1)) and @ismbr(&OEP_FcstMnth:&OEP_EndMnth)) or (@ismbr(@remove(&OEP_RollingFCST, @list(&OEP_CurYr, @MEMBERAT(&OEP_RollingFCST, -1)))) and @ismbr(@relative("YearTotal",0))) or (@ismbr(@MEMBERAT(&OEP_RollingFCST, -1)) and @ismbr(&OEP_StartMnth:&OEP_RollingFCSTEnd)))																			
                                   if(Not(@ismbr("No Year")))
                                    %Script(name:="Monthly_Trends") 													
                                    %Script(name:="Forecast_Only_Trends")													
                                    endif	        
                                   endif

                            elseif (@ismbr(&OEP_QrtlyFCSTRF))
                                if(@ismbr(@relative("OEP_Qrtly Plan", 0)))															
                                    if(not(@ismbr("No Year")))														
                                        %Script(name:="Qrtly_Trends")																									
                                    endif		
                                endif
                            endif
                        endif  '''
           
			  //Intermediate calcscript goes here
			
            if(weeklyPlanExists){
             	cscript.append(weeklyTrendLogic);
            }else{
            	cscript.append(nonWeeklyTrendLogic);
            }
			

            if(operation.application.currencyMode == CurrencyMode.SIMPLIFIED_MULTI_CURRENCY) {
            	cscript.append("\nENDIF \n");
            }
             
            cscript.append(") \n");
			cscript.append("\nENDFIX \n");
        }

        String msg = "ENDFIX \n";
        cscript.append(msg);

        return cscript.toString();]]></script></rule></rules><components><component id="2" name="Forecast_Only_Trends" product="Planning" type="script"><property name="application">HP4</property><property name="plantype">OEP_FS</property><property name="display_label">Forecast_Only_Trends</property><property name="seeded">true</property><script type="calcscript"><![CDATA[elseif("OFS_Trend"->"BegBalance"==10)
				if(@isuda("Account","calcRound"))
                	IF(@ISMBR(&OEP_CurYr))
						"OFS_Calculated" = @Round(@prior("Actual"->"OFS_Total Plan"->"YearTotal",1,@LEVMBRS ("Years", 0))/12*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
                    ELSE
                    	"OFS_Calculated" = @Round(@prior("OFS_Total Plan"->"YearTotal",1,@LEVMBRS ("Years", 0))/12*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
                    ENDIF    
				else
                	IF(@ISMBR(&OEP_CurYr))
						"OFS_Calculated" = @prior("Actual"->"OFS_Total Plan"->"YearTotal",1,@LEVMBRS ("Years", 0))/12*(1+"OFS_% Increase/(Decrease)"->"BegBalance");
                    ELSE
                    	"OFS_Calculated" = @prior("OFS_Total Plan"->"YearTotal",1,@LEVMBRS ("Years", 0))/12*(1+"OFS_% Increase/(Decrease)"->"BegBalance");
                    ENDIF    
				endif
elseif("OFS_Trend"->"BegBalance"==3)
			if(@sumrange("OEP_Plan"->"OFS_Total Plan",&OEP_StartMnth:&OEP_EndMnth)-@sumrange("OEP_Actual"->"OFS_Load",&OEP_StartMnth:&OEP_CurMnth)>0)
				if(@ISACCTYPE(LAST))
					if(@isuda("Account","Calcround"))
						"OFS_Calculated"=@round("OEP_Plan"->"OFS_Total Plan");
					else
						"OFS_Calculated" ="OEP_Plan"->"OFS_Total Plan";
					endif
				else
					if(@isuda("Account","Calcround"))
						"OFS_Calculated"=@round(((@sumrange("OEP_Plan"->"OFS_Total Plan",&OEP_StartMnth:&OEP_EndMnth))-(@sumrange("OEP_Actual"->"OFS_Load",&OEP_StartMnth:&OEP_CurMnth)))/@count(skipnone,&OEP_FcstMnth:&OEP_EndMnth));
					else
						"OFS_Calculated"=((@sumrange("OEP_Plan"->"OFS_Total Plan",&OEP_StartMnth:&OEP_EndMnth))-(@sumrange("OEP_Actual"->"OFS_Load",&OEP_StartMnth:&OEP_CurMnth)))/@count(skipnone,&OEP_FcstMnth:&OEP_EndMnth);
					endif
				endif
			else
				"OFS_Calculated"=#missing;
			endif
    @calcmode(cell);
		elseif("OFS_Trend"->"BegBalance"==35)			
			if(@ismbr(&OEP_FCSTStartYr))
				if(@ismbr(&OEP_FcstMnth))
					if(@ismbr(@MBRCOMPARE("==", &OEP_FcstMnth, &OEP_StartMnth)))
						if(@isuda("Account","calcRound"))
							OFS_Calculated=@round((@prior("OFS_Load"->OEP_Actual->&OEP_EndMnth,1,@levmbrs(Years,0))*(@prior("OFS_Load"->OEP_Actual,1,@LEVMBRS ("Years", 0))+@prior("OFS_Load"->OEP_Actual,2,@LEVMBRS ("Years", 0)))/					
							(@prior( "OFS_Load"->OEP_Actual->&OEP_EndMnth, 2,@levmbrs(Years,0) )+@prior( "OFS_Load"->OEP_Actual->&OEP_EndMnth, 3,@levmbrs(Years,0) )))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
						else
							OFS_Calculated=((@prior("OFS_Load"->OEP_Actual->&OEP_EndMnth,1,@levmbrs(Years,0))*(@prior("OFS_Load"->OEP_Actual,1,@LEVMBRS ("Years", 0))+@prior("OFS_Load"->OEP_Actual,2,@LEVMBRS ("Years", 0)))/
  							(@prior( "OFS_Load"->OEP_Actual->&OEP_EndMnth, 2,@levmbrs(Years,0) )+@prior( "OFS_Load"->OEP_Actual->&OEP_EndMnth, 3,@levmbrs(Years,0) )))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
						endif
					else
						if(@isuda("Account","calcRound"))
							OFS_Calculated=@round((@prior("OFS_Load"->OEP_Actual->&OEP_CurYr)*(@prior("OFS_Load"->OEP_Actual,1,@LEVMBRS ("Years", 0))+@prior("OFS_Load"->OEP_Actual,2,@LEVMBRS ("Years", 0)))/					
							(@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative(YearTotal,0) , -1, "Years", )+@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative(YearTotal,0) , -2, "Years", )))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
						else
							OFS_Calculated=((@prior("OFS_Load"->OEP_Actual->&OEP_CurYr)*(@prior("OFS_Load"->OEP_Actual,1,@LEVMBRS ("Years", 0))+@prior("OFS_Load"->OEP_Actual,2,@LEVMBRS ("Years", 0)))/					
							(@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative(YearTotal,0) , -1, "Years", )+@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative(YearTotal,0) , -2, "Years", )))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
						endif
					endif
				else
					if(@isuda("Account","calcRound"))
						OFS_Calculated=@round((@prior("OFS_Calculated")*(@prior("OFS_Load"->OEP_Actual,1,@LEVMBRS ("Years", 0))+@prior("OFS_Load"->OEP_Actual,2,@LEVMBRS ("Years", 0)))/
                        (@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative(YearTotal,0) , -1, "Years", )+@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative(YearTotal,0) , -2, "Years", )))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
					else
						OFS_Calculated=((@prior("OFS_Calculated")*(@prior("OFS_Load"->OEP_Actual,1,@LEVMBRS ("Years", 0))+@prior("OFS_Load"->OEP_Actual,2,@LEVMBRS ("Years", 0)))/
                        (@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative(YearTotal,0) , -1, "Years", )+@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative(YearTotal,0) , -2, "Years", )))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
					endif
				endif
			elseif(@ismbr(@RSIBLINGS(&OEP_FCSTStartYr)))
				if(@ismbr(&OEP_StartMnth))
					if(@isuda("Account","calcRound"))
						OFS_Calculated=@round((@prior("OFS_Calculated"->&OEP_EndMnth,1,@levmbrs(Years,0))*(@prior("OFS_Calculated",1,@LEVMBRS ("Years", 0))+@prior("OFS_Load"->OEP_Actual,2,@LEVMBRS ("Years", 0)))/					
						(@prior( "OFS_Load"->OEP_Actual->&OEP_EndMnth, 2,@levmbrs(Years,0) )+@prior( "OFS_Load"->OEP_Actual->&OEP_EndMnth, 3,@levmbrs(Years,0))))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
					else
						OFS_Calculated=((@prior("OFS_Calculated"->&OEP_EndMnth,1,@levmbrs(Years,0))*(@prior("OFS_Calculated",1,@LEVMBRS ("Years", 0))+@prior("OFS_Load"->OEP_Actual,2,@LEVMBRS ("Years", 0)))/
                        (@prior( "OFS_Load"->OEP_Actual->&OEP_EndMnth, 2,@levmbrs(Years,0) )+@prior( "OFS_Load"->OEP_Actual->&OEP_EndMnth, 3,@levmbrs(Years,0))))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
					endif
				else
					if(@isuda("Account","calcRound"))
						OFS_Calculated=@round((@prior("OFS_Calculated")*(@prior("OFS_Calculated",1,@LEVMBRS ("Years", 0))+@prior("OFS_Load"->OEP_Actual,2,@LEVMBRS ("Years", 0)))/					
						(@MDSHIFT( "OFS_Calculated", -1, "Period",@relative(YearTotal,0) , -1, "Years", )+@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative(YearTotal,0) , -2, "Years", )))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
					else
						OFS_Calculated=((@prior("OFS_Calculated")*(@prior("OFS_Calculated",1,@LEVMBRS ("Years", 0))+@prior("OFS_Load"->OEP_Actual,2,@LEVMBRS ("Years", 0)))/
                        (@MDSHIFT( "OFS_Calculated", -1, "Period",@relative(YearTotal,0) , -1, "Years", )+@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative(YearTotal,0) , -2, "Years", )))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
					endif
				endif
			endif
	@calcmode(block);
		elseif("OFS_Trend"->"BegBalance"==36)			
			if(@isuda("Account","calcRound"))					
		if(@ismbr(&OEP_FcstMnth) and @ismbr(&OEP_FcstStartYr))	
			"OFS_Calculated"=@round((@prior("OFS_Load"->OEP_Actual->&OEP_CurYr))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));			
		elseif(@ismbr(&OEP_StartMnth) and @ismbr(@RSIBLINGS(&OEP_FCSTStartYr)))
       		"OFS_Calculated"=@round((@Prior("OFS_Total Plan"->&OEP_EndMnth,1,@LEVMBRS ("Years", 0)))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
				else			
			"OFS_Calculated" =@round((@prior("OFS_Calculated")+@prior("OFS_Adjustment (+/-)"))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));			
				endif	
			else		
		if(@ismbr(&OEP_FcstMnth) and @ismbr(&OEP_FcstStartYr))	
			"OFS_Calculated"=@prior("OFS_Load"->OEP_Actual->&OEP_CurYr)*(1+"OFS_% Increase/(Decrease)"->"BegBalance");			
		elseif(@ismbr(&OEP_StartMnth) and @ismbr(@RSIBLINGS(&OEP_FCSTStartYr)))
        	"OFS_Calculated"=@Prior("OFS_Total Plan"->&OEP_EndMnth,1,@LEVMBRS ("Years", 0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance");
				else
			"OFS_Calculated" =(@prior("OFS_Calculated")+@prior("OFS_Adjustment (+/-)"))*(1+"OFS_% Increase/(Decrease)"->"BegBalance");			
				endif	
			endif]]></script></component><component id="1" name="Monthly_Trends" product="Planning" type="script"><property name="application">HP4</property><property name="plantype">OEP_FS</property><property name="display_label">Monthly_Trends</property><property name="seeded">true</property><script type="calcscript"><![CDATA[If("OFS_Trend"->"BegBalance"==1)						
	if(@isuda("Account","CalcRound"))					
		OFS_Calculated = @Round(@AVGRANGE(SKIPNONE , "OEP_Actual"->"OFS_Load"->&OEP_CurYr , &OEP_StartMnth:&OEP_CurMnth)*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));				
	else					
		OFS_Calculated =@AVGRANGE(SKIPNONE , "OEP_Actual"->"OFS_Load"->&OEP_CurYr , &OEP_StartMnth:&OEP_CurMnth)*(1+"OFS_% Increase/(Decrease)"->"BegBalance");				
	endif					
elseif("OFS_Trend"->"BegBalance"==2)						
	if(@isuda("Account","CalcRound"))					
		OFS_Calculated =@Round(("OEP_Actual"->&OEP_CurMnth->&OEP_CurYr->"OFS_Load")*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));				
	else					
		OFS_Calculated = ("OEP_Actual"->&OEP_CurMnth->&OEP_CurYr->"OFS_Load")*(1+"OFS_% Increase/(Decrease)"->"BegBalance");				
	endif					
						
elseif("OFS_Trend"->"BegBalance"==4)						
	if(@isuda("Account","CalcRound"))					
		OFS_Calculated = @Round(@avgrange(skipnone,"OEP_Actual"->"OFS_Load"->&OEP_PriorYr,@relative("YearTotal",0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));				
	else					
		OFS_Calculated = @avgrange(skipnone,"OEP_Actual"->"OFS_Load"->&OEP_PriorYr,@relative("YearTotal",0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance");				
	endif					
elseif("OFS_Trend"->"BegBalance"==5)						
	if(@isuda("Account","CalcRound"))					
		OFS_Calculated = @Round(("OEP_Actual"->"OFS_Load"->&OEP_PriorYr)*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));				
	else					
		OFS_Calculated = ("OEP_Actual"->"OFS_Load"->&OEP_PriorYr)*(1+"OFS_% Increase/(Decrease)"->"BegBalance");				
	endif					
elseif("OFS_Trend"->BegBalance==12)						
	OFS_Calculated =#missing;					
elseif("OFS_Trend"->BegBalance==#missing and "OFS_Adjustment (+/-)"<>#missing)										
	OFS_Calculated=0;
    OFS_Calculated=#missing;					
					
]]></script></component><component id="5" name="Qrtly_Trends" product="Planning" type="script"><property name="application">HP4</property><property name="plantype">OEP_FS</property><property name="display_label">Qrtly_Trends</property><property name="seeded">true</property><script type="calcscript"><![CDATA[If("OFS_Trend"->"BegBalance"==1)										
		if(@isuda("Account","CalcRound"))	
        	if(@isuda("Account","Flow"))
				"OFS_Calculated" = @Round((@AVGRANGE(SKIPNONE , "OEP_Actual"->"OFS_Load"->&OEP_CurYr , &OEP_StartMnth:&OEP_CurMnth))*"PeriodsInQtr"*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
            else
            	"OFS_Calculated" = @Round((@AVGRANGE(SKIPNONE , "OEP_Actual"->"OFS_Load"->&OEP_CurYr , &OEP_StartMnth:&OEP_CurMnth))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
            endif
		else
        	if(@isuda("Account","Flow"))
				OFS_Calculated =(@AVGRANGE(SKIPNONE , "OEP_Actual"->"OFS_Load"->&OEP_CurYr , &OEP_StartMnth:&OEP_CurMnth))*"PeriodsInQtr"*(1+"OFS_% Increase/(Decrease)"->"BegBalance");			
            else
            	OFS_Calculated =(@AVGRANGE(SKIPNONE , "OEP_Actual"->"OFS_Load"->&OEP_CurYr , &OEP_StartMnth:&OEP_CurMnth))*(1+"OFS_% Increase/(Decrease)"->"BegBalance");		
            endif
		endif									
elseif("OFS_Trend"->"BegBalance"==2)										
		if(@isuda("Account","CalcRound"))
        	if(@isuda("Account","Flow"))
				OFS_Calculated =@Round((("OEP_Actual"->&OEP_CurMnth->&OEP_CurYr->"OFS_Load")*"PeriodsInQtr")*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));	
            else
            	OFS_Calculated =@Round((("OEP_Actual"->&OEP_CurMnth->&OEP_CurYr->"OFS_Load"))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));	
            endif
		else	
        	if(@isuda("Account","Flow"))
				OFS_Calculated = (("OEP_Actual"->&OEP_CurMnth->&OEP_CurYr->"OFS_Load")*"PeriodsInQtr")*(1+"OFS_% Increase/(Decrease)"->"BegBalance");	
            else
            	OFS_Calculated = (("OEP_Actual"->&OEP_CurMnth->&OEP_CurYr->"OFS_Load"))*(1+"OFS_% Increase/(Decrease)"->"BegBalance");	
            endif
		endif									
	elseif("OFS_Trend"->"BegBalance"==4)										
		if(@isuda("Account","CalcRound"))		
        	if(@isuda("Account","Flow"))
				OFS_Calculated = @Round((@avgrange(skipnone,"OEP_Actual"->"OFS_Load"->&OEP_PriorYr,@relative("YearTotal",0))*"PeriodsInQtr")*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));		
            else
           		OFS_Calculated = @Round((@avgrange(skipnone,"OEP_Actual"->"OFS_Load"->&OEP_PriorYr,@relative("YearTotal",0)))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));	
            endif
		else	
        	if(@isuda("Account","Flow"))
				OFS_Calculated = (@avgrange(skipnone,"OEP_Actual"->"OFS_Load"->&OEP_PriorYr,@relative("YearTotal",0))*"PeriodsInQtr")*(1+"OFS_% Increase/(Decrease)"->"BegBalance");	
            else
            	OFS_Calculated = (@avgrange(skipnone,"OEP_Actual"->"OFS_Load"->&OEP_PriorYr,@relative("YearTotal",0)))*(1+"OFS_% Increase/(Decrease)"->"BegBalance");
            endif
		endif												
	elseif("OFS_Trend"->"BegBalance"==10)										
		if(@prior("OEP_Qrtly Plan",1,@levmbrs("Years",0))<>#Missing)									
			if(@isuda("Account","CalcRound"))								
				@Round(@Prior("OFS_Total Plan",1,@LEVMBRS ("Years", 0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));							
			else								
				@Prior("OFS_Total Plan",1,@LEVMBRS ("Years", 0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance");							
			endif								
		else									
			if(@isuda("Account","CalcRound"))								
				if(@ismbr("Qtrly 1"))							
					@Round(@Prior("OFS_Total Plan"->"Q1",1,@LEVMBRS ("Years", 0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));						
				elseif(@ismbr("Qtrly 2"))							
					@Round(@Prior("OFS_Total Plan"->"Q2",1,@LEVMBRS ("Years", 0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));						
				elseif(@ismbr("Qtrly 3"))							
					@Round(@Prior("OFS_Total Plan"->"Q3",1,@LEVMBRS ("Years", 0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));						
				elseif(@ismbr("Qtrly 4"))							
					@Round(@Prior("OFS_Total Plan"->"Q4",1,@LEVMBRS ("Years", 0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));						
				endif							
			else								
				if(@ismbr("Qtrly 1"))							
					@Prior("OFS_Total Plan"->"Q1",1,@LEVMBRS ("Years", 0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance");						
				elseif(@ismbr("Qtrly 2"))							
					@Prior("OFS_Total Plan"->"Q2",1,@LEVMBRS ("Years", 0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance");						
				elseif(@ismbr("Qtrly 3"))							
					@Prior("OFS_Total Plan"->"Q3",1,@LEVMBRS ("Years", 0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance");						
				elseif(@ismbr("Qtrly 4"))							
					@Prior("OFS_Total Plan"->"Q4",1,@LEVMBRS ("Years", 0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance");						
				endif							
			endif								
											
		endif									
	elseif("OFS_Trend"->BegBalance==12)										
				OFS_Calculated=#missing;							
	elseif("OFS_Trend"->BegBalance==#missing and "OFS_Adjustment (+/-)"<>#missing)																
				OFS_Calculated=0;
                OFS_Calculated=#missing;							
	endif										

]]></script></component><component id="4" name="Weekly_ForecastOnly" product="Planning" type="script"><property name="application">HP4</property><property name="plantype">OEP_FS</property><property name="display_label">Weekly_ForecastOnly</property><property name="seeded">true</property><script type="calcscript"><![CDATA[elseif("OFS_Trend"->"BegBalance"==3)						
	if(("OEP_Plan"->"OFS_Total Plan"->"OEP_Weekly Plan")-@sumrange("OEP_Actual"->"OFS_Load",OEP_W1:&OEP_CurWeek)>0)							
          if(@ISACCTYPE(LAST))				
              if(@isuda("Account","Calcround"))			
                  "OFS_Calculated"=@round("OEP_Plan"->"OFS_Total Plan");		
              else			
                  "OFS_Calculated" ="OEP_Plan"->"OFS_Total Plan";		
              endif			
          else				
              	if(@isuda("Account","Calcround"))		
				"OFS_Calculated"=@round((("OEP_Plan"->"OFS_Total Plan"->"OEP_Weekly Plan")-@sumrange("OEP_Actual"->"OFS_Load",OEP_W1:&OEP_CurWeek))/("TP-Weeks"-@count(skipnone,@range("OFS_Load",OEP_W1:&OEP_CurWeek))));				
                  else
				"OFS_Calculated"=((("OEP_Plan"->"OFS_Total Plan"->"OEP_Weekly Plan")-@sumrange("OEP_Actual"->"OFS_Load",OEP_W1:&OEP_CurWeek))/("TP-Weeks"-@count(skipnone,@range("OFS_Direct Input",OEP_W1:&OEP_CurWeek))));				
              endif			
          endif				
      else					
          "OFS_Calculated"=#missing;				
      endif	
elseif("OFS_Trend"->"BegBalance"==35)			
  	if(@isuda("Account","calcRound"))		  			
  		if(@ismbr(&OEP_FcstMnth))	
			"OFS_Calculated"=@round((@prior("OFS_Load"->OEP_Actual->&OEP_CurYr)*(@prior("OFS_Load"->OEP_Actual,1,@LEVMBRS ("Years", 0))+@prior("OFS_Load"->OEP_Actual,2,@LEVMBRS ("Years", 0)))/					
			(@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative("OEP_Weekly Plan",0) , -1, "Years", )+@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative("OEP_Weekly Plan",0) , -2, "Years", )))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));					
  		else
			"OFS_Calculated" =@round((@prior("OFS_Calculated")*					
  			(@prior("OFS_Load"->OEP_Actual,1,@LEVMBRS ("Years", 0))+@prior("OFS_Load"->OEP_Actual,2,@LEVMBRS ("Years", 0)))/
			(@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative("OEP_Weekly Plan",0) , -1, "Years", )+@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative("OEP_Weekly Plan",0) , -2, "Years", )))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));					
  		endif	
  	else		
  		if(@ismbr(&OEP_FcstMnth))	
			"OFS_Calculated"=((@prior("OFS_Load"->OEP_Actual->&OEP_CurYr)*(@prior("OFS_Load"->OEP_Actual,1,@LEVMBRS ("Years", 0))+@prior("OFS_Load"->OEP_Actual,2,@LEVMBRS ("Years", 0)))/					
			(@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative("OEP_Weekly Plan",0) , -1, "Years", )+@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative("OEP_Weekly Plan",0) , -2, "Years", )))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));					
  	 	else	 			
			"OFS_Calculated" =((@prior("OFS_Calculated")*					
  			(@prior("OFS_Load"->OEP_Actual,1,@LEVMBRS ("Years", 0))+@prior("OFS_Load"->OEP_Actual,2,@LEVMBRS ("Years", 0)))/
			(@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative("OEP_Weekly Plan",0) , -1, "Years", )+@MDSHIFT( "OFS_Load"->OEP_Actual, -1, "Period",@relative("OEP_Weekly Plan",0) , -2, "Years", )))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));  					
  		endif	
  	endif	
elseif("OFS_Trend"->"BegBalance"==36)			
	if(@isuda("Account","calcRound"))					
		if(Not(@ismbr(OEP_W1:&OEP_CurWeek) and @ismbr(&OEP_CurYr)))	
			"OFS_Calculated"=@round((@prior("OFS_Load"->OEP_Actual->&OEP_CurYr))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));			
		elseif(@ismbr(OEP_W1) and @ismbr(@RSIBLINGS(&OEP_CurYr)))
       		"OFS_Calculated"=@round((@Prior("OFS_Total Plan"->OEP_W52,1,@LEVMBRS ("Years", 0)))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));
        else			
			"OFS_Calculated" =@round((@prior("OFS_Calculated")+@prior("OFS_Adjustment (+/-)"))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));			
		endif	
	else		
		if(Not(@ismbr(OEP_W1:&OEP_CurWeek) and @ismbr(&OEP_CurYr)))	
			"OFS_Calculated"=@prior("OFS_Load"->OEP_Actual->&OEP_CurYr)*(1+"OFS_% Increase/(Decrease)"->"BegBalance");			
		elseif(@ismbr(OEP_W1) and @ismbr(@RSIBLINGS(&OEP_CurYr)))
        	"OFS_Calculated"=@Prior("OFS_Total Plan"->OEP_W52,1,@LEVMBRS ("Years", 0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance");
        else
			"OFS_Calculated" =(@prior("OFS_Calculated")+@prior("OFS_Adjustment (+/-)"))*(1+"OFS_% Increase/(Decrease)"->"BegBalance");			
		endif	
	endif           ]]></script></component><component id="3" name="Weekly_Trends" product="Planning" type="script"><property name="application">HP4</property><property name="plantype">OEP_FS</property><property name="display_label">Weekly_Trends</property><property name="seeded">true</property><script type="calcscript"><![CDATA[If("OFS_Trend"->"BegBalance"==1)						
	if(@isuda("Account","CalcRound"))					
		"OFS_Calculated"=@Round(@AVGRANGE(SKIPNONE , "OEP_Actual"->"OFS_Load"->&OEP_CurYr , OEP_W1:&OEP_CurWeek)*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));				
	else					
		"OFS_Calculated"=@AVGRANGE(SKIPNONE , "OEP_Actual"->"OFS_Load"->&OEP_CurYr , OEP_W1:&OEP_CurWeek)*(1+"OFS_% Increase/(Decrease)"->"BegBalance");				
	endif					
elseif("OFS_Trend"->"BegBalance"==2)						
	if(@isuda("Account","CalcRound"))					
		"OFS_Calculated"=@Round(("OEP_Actual"->&OEP_CurWeek->&OEP_CurYr->"OFS_Load")*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));				
	else					
		"OFS_Calculated"=("OEP_Actual"->&OEP_CurWeek->&OEP_CurYr->"OFS_Load")*(1+"OFS_% Increase/(Decrease)"->"BegBalance");				
	endif					
elseif("OFS_Trend"->"BegBalance"==4)
	if("TP-Weeks"->&OEP_PriorYr==52)        
		if(@isuda("Account","CalcRound"))	 		  
			"OFS_Calculated"= @Round(@avgrange(skipnone,"OEP_Actual"->"OFS_Load"->&OEP_PriorYr,OEP_W1:OEP_W52)*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));				
		else					
			"OFS_Calculated"= @avgrange(skipnone,"OEP_Actual"->"OFS_Load"->&OEP_PriorYr,OEP_W1:OEP_W52)*(1+"OFS_% Increase/(Decrease)"->"BegBalance");				
		endif
	else       
		if(@isuda("Account","CalcRound"))	 		  
			"OFS_Calculated"= @Round(@avgrange(skipnone,"OEP_Actual"->"OFS_Load"->&OEP_PriorYr,@relative("OEP_Weekly Plan",0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));				
		else					
			"OFS_Calculated"= @avgrange(skipnone,"OEP_Actual"->"OFS_Load"->&OEP_PriorYr,@relative("OEP_Weekly Plan",0))*(1+"OFS_% Increase/(Decrease)"->"BegBalance");				
		endif
	endif
elseif("OFS_Trend"->"BegBalance"==5)						
	if(@isuda("Account","CalcRound"))					
		"OFS_Calculated"= @Round(("OEP_Actual"->"OFS_Load"->&OEP_PriorYr)*(1+"OFS_% Increase/(Decrease)"->"BegBalance"));				
	else					
		"OFS_Calculated"= ("OEP_Actual"->"OFS_Load"->&OEP_PriorYr)*(1+"OFS_% Increase/(Decrease)"->"BegBalance");				
	endif					
elseif("OFS_Trend"->BegBalance==12)						
	"OFS_Calculated"=#missing;					
elseif("OFS_Trend"->BegBalance==#missing and "OFS_Adjustment (+/-)"<>#missing)										
	OFS_Calculated=0;
    OFS_Calculated=#missing;					]]></script></component></components><deployobjects><deployobject application="hp4" name="OFS_ROLLING TREND BASED CALC" obj_id="1" obj_type="1" plantype="oep_fs" product="2"/></deployobjects></HBRRepo>